package com.bawei.mall.product.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bawei.common.log.annotation.Log;
import com.bawei.common.log.enums.BusinessType;
import com.bawei.common.security.annotation.RequiresPermissions;
import com.bawei.mall.product.domain.MallProductGao;
import com.bawei.mall.product.service.IMallProductGaoService;
import com.bawei.common.core.web.controller.BaseController;
import com.bawei.common.core.web.domain.AjaxResult;
import com.bawei.common.core.utils.poi.ExcelUtil;
import com.bawei.common.core.web.page.TableDataInfo;

/**
 * gaoController
 *
 * @author duanguohong
 * @date 2024-07-02
 */
@RestController
@RequestMapping("/gao")
public class MallProductGaoController extends BaseController
{
    @Autowired
    private IMallProductGaoService mallProductGaoService;

    /**
     * 功能：查询gao列表
     */
    @RequiresPermissions("product:gao:list")
    @GetMapping("/list")
    public TableDataInfo list(MallProductGao mallProductGao)
    {
        startPage();
        List<MallProductGao> list = mallProductGaoService.selectMallProductGaoList(mallProductGao);
        return getDataTable(list);
    }

    /**
     * 功能：导出gao列表
     */
    @RequiresPermissions("product:gao:export")
    @Log(title = "gao", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallProductGao mallProductGao)
    {
        List<MallProductGao> list = mallProductGaoService.selectMallProductGaoList(mallProductGao);
        ExcelUtil<MallProductGao> util = new ExcelUtil<MallProductGao>(MallProductGao.class);
        util.exportExcel(response, list, "gao数据");
    }

    /**
     * 功能：获取广告详细信息
     */
    @RequiresPermissions("product:gao:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mallProductGaoService.selectMallProductGaoById(id));
    }

    /**
     * 功能：新增广告
     */
    @RequiresPermissions("product:gao:add")
    @Log(title = "gao", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallProductGao mallProductGao)
    {
        return toAjax(mallProductGaoService.insertMallProductGao(mallProductGao));
    }

    /**
     * 功能：修改广告
     */
    @RequiresPermissions("product:gao:edit")
    @Log(title = "gao", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallProductGao mallProductGao)
    {
        return toAjax(mallProductGaoService.updateMallProductGao(mallProductGao));
    }

    /**
     * 功能：删除广告
     */
    @RequiresPermissions("product:gao:remove")
    @Log(title = "gao", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mallProductGaoService.deleteMallProductGaoByIds(ids));
    }
}
